/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2024-06-01
 * Time: 15:46
import java.util.Arrays;

public class Test {
    public static void func(int[] array){
        int left = 0;
        int right = array.length - 1;
        while(left < right){
            while (left < right && array[left] % 2 == 1) {
                left++;
            }
            while(left < right && array[right] % 2 == 0){
                right--;
            }
            int tmp = array[left];
            array[left] = array[right];
            array[right] = tmp;
        }
    }

    public static void main(String[] args) {
        int[] array = { 1, 2, 3, 5, 7, 4 };
        func(array);
        System.out.println(Arrays.toString(array));
    }
}*/





/*
public class Test {
    public static boolean func(int[] array){
        int count = 0;
        for (int i = 0; i < array.length; i++) {
            if(array[i] % 2 != 0){
                count++;
                if(count == 3){
                    return true;
                }
            } else {
                count = 0;
            }
        }
        return false;
    }
    public static void main(String[] args) {
        int[] array = { 1, 2, 1, 3, 1, 2, 1, 1, 3};
        System.out.println(func(array));
    }
}*/



/*public class Test {

    public static void ret(int[] array) {
        int ret = 0;
        int ret1 = 0;
        int i = 0;
            while ((i < array.length) && ((array[i] >> 1) & 1) == 1) {
               ret =  array[i];
               ret ^= array[i];
               i++;
            }
            System.out.println(ret);
            while ((i < array.length) && ((array[i] >> 1) & 1) == 0){
                ret1 =  array[i];
                ret1 ^= array[i];
                i++;
            }
            System.out.println(ret1);
        }


    public static void numList(int[] array){
        int ret = findNum(array);
        for (int i = 31; i >= 0; i--) {
          System.out.print(((ret >>> i) & 1) + " ");
        }
        System.out.println();
    }

    public static int findNum(int[] array){
        int ret = array[0];
        for (int i = 1; i < array.length; i++) {
            ret ^= array[i];
        }
        return ret;
    }
    public static void main(String[] args) {
        int[] array = {1, 2 , 2, 1, 3, 4, 5, 5};
        numList(array);
        ret(array);
    }
}*/







/*
public class Test {

    public static void ret(int[] array) {
        int ret = 0;
        int ret1 = 0;
        for (int i = 0; i < array.length; i++) {
            if(((array[i]>>1)&1) == 1){
                ret^=array[i];
            }else{
                ret1^= array[i];
            }
        }
        System.out.println(ret);
        System.out.println(ret1);
    }


    public static void numList(int[] array){
        int ret = findNum(array);
        for (int i = 31; i >= 0; i--) {
            System.out.print(((ret >>> i) & 1) + " ");
        }
        System.out.println();
    }

    public static int findNum(int[] array){
        int ret = array[0];
        for (int i = 1; i < array.length; i++) {
            ret ^= array[i];
        }
        return ret;
    }
    public static void main(String[] args) {
        int[] array = {1, 2 , 2, 1, 3, 4, 5, 5};
        numList(array);
        ret(array);
    }
}
*/




/*
import java.util.Arrays;
import java.util.Scanner;

public class Test {
    public static int[] func(int[] array , int k){
        for (int i = 0; i < array.length - 1 ; i++) {
            for (int j = i + 1; j < array.length; j++) {
                if(array[i] + array[j] == k){
                    return new int[] {i , j};
                }
            }
        }
        return new int[]{ -1 , -1};
    }

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int[] array = {2, 7 , 11 , 15 };
        int k = scan.nextInt();
        int[] ret = func(array , k);
        System.out.println(Arrays.toString(ret));
    }
}
*/



//求数组中只出现了1次的数字

/*
public class Test {
    public static int findNum(int[] array){
        int ret = array[0];
        for (int i = 1; i < array.length; i++) {
            ret ^= array[i];
        }
        return ret;
    }

    public static void main(String[] args) {
        int[] array = { 1, 3, 2, 2, 1};
        System.out.println(findNum(array));
    }
}*/



/*public class Test {
    public static void main(String[] args) {
        int[][] array1 = {{1, 2, 3},{4 , 5 ,6 }};
        int[][] array2 = new int[][]{{1, 2, 3},{4 , 5 ,6 }};
        int[][] array3 = new int[2][3];//[行的个数][列的个数];
    }
}*/

/*
import java.util.Arrays;

public class Test {
    public static void reverstring(int[] array){
        int left = 0;
        int right = array.length - 1;
        while (left < right) {
            int tmp = array[left];
            array[left] = array[right];
            array[right] = tmp;
            left++;
            right--;
        }
    }

    public static void main(String[] args) {
        int[] array = { 1, 12, 43, 24, 5, 76, 21 };
        reverstring(array);
        System.out.println(Arrays.toString(array));
    }
}*/




//二维数组的遍历

/*
import java.util.Arrays;

public class Test{
    public static void func(int[][] array){
        for (int i = 0; i < 2; i++) {
            for (int j = 0; j < 3; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }
    public static void main(String[] args) {
        int[][] array= new int[][]{{1, 2, 3},{4, 5, 6}};
        int[][] array1 = new int[2][3];
        int[][] array2 = {{1, 2, 3},{4, 5, 6}};
        func(array);
        System.out.println(Arrays.toString(array));
    }
}*/



/*
public class Test {
    public static void main(String[] args) {
        int[][] array1 = {{1, 2, 3},{4 , 5 ,6 }};
        System.out.println(array1[0]);
        System.out.println(array1[1]);
        System.out.println(array1[0].length);
        System.out.println(array1[1].length);
        System.out.println(array1.length);
    }
}*/




/*
import java.util.Arrays;

public class Test {
    public static void func(int[][] array){
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            System.out.println();
        }
    }
    public static void main(String[] args) {
        int[][] array= new int[][]{{1, 2, 3},{4, 5, 6}};
        int[][] array1 = new int[2][3];
        int[][] array2 = {{1, 2, 3},{4, 5, 6}};
        func(array);
        System.out.println(Arrays.toString(array[0]));
        System.out.println(Arrays.toString(array[1]));
        System.out.println(Arrays.deepToString(array));
    }
}*/




/*
import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        int[][] array= new int[2][];
        array[0] = new int[]{1, 2 ,3};
        array[1] = new int[]{4 , 6 , 7 , 11 , 14 , 16};
        System.out.println(Arrays.deepToString(array));
    }
}*/


/*class Dog{
    public String name;
    public int age;
    public String color;

    public void eat(){
        System.out.println(name + "进食");
    }

    public void barks(){
        System.out.println(name + "吠叫");
    }
}

public class Test{
    public static void main(String[] args){
        Dog petDog = new Dog();
        petDog.name = "初一";
        petDog.age = 10;
        petDog.color = "黄色";
        System.out.println(petDog.name);
        System.out.println(petDog.age);
        System.out.println(petDog.color);
        petDog.eat();
        petDog.barks();

        System.out.println("=====================");

        Dog petDog2 = new Dog();
        //new关键字用于创建一个对象的实例.
        //使用 . 来访问对象中的属性和方法.
        //同一个类可以创建多个实例.
        petDog2.name = "初二";
        petDog2.age = 12;
        petDog2.color = "黑色";
        System.out.println(petDog2.name);
        System.out.println(petDog2.age);
        System.out.println(petDog2.color);
        petDog2.eat();
        petDog2.barks();
    }
}*/



/*class Data{
    public int year;
    public int month;
    public int day;

    public void setDay(int year,int month,int day){
        this.year = year;
        this.month = month;
        this.day = day;
    }

    public void printDay(){
        System.out.println("年："+ this.year + " " + "月：" + this.month + " " + "日：" + this.day + " ");
    }
}

public class Test {
    public static void main(String[] args) {
        Data date = new Data();
        date.setDay(2023 , 7 ,20);
        date.printDay();
        Data date2 = new Data();
        date.setDay(2021 , 1 ,21);
        date.printDay();
    }
}*/




/*
class Date{
    public int year;
    public int month;
    public int day;

    public void setDate(int y , int m ,int d){
        year = y;
        month = m;
        day = d;
    }
    public void printDate(){
        System.out.println("年:" + year + " "+ "月:" + month + " " + "日:" + day);
    }

    public static void main(String[] args) {
        Date date = new Date();
        date.setDate(2022 , 5 , 20 );
        date.printDate();
    }
}*/





/*class Student{
    //成员变量定义在方法的外面，类的内部。
    public String name;
    public int age;
    public String gender;

    public void eat(){
        System.out.println(this.name + "正在吃饭");
        //这里的this是当前对象的引用，谁调用eat谁就是this。
    }
}


public class Test{
    public static void main(String[] args) {
        Student student = new Student();
        student.name = "张三";
        student.age = 10;
        student.gender = "男";
        System.out.println(student.name);
        System.out.println(student.age);
        System.out.println(student.gender);
        student.eat();

        System.out.println("=====================");

        Student student2 = new Student();
        student2.name = "李素";
        student2.age = 11;
        student2.gender = "女";
        System.out.println(student2.name);
        System.out.println(student2.age);
        System.out.println(student2.gender);
        student2.eat();
    }
}*/







/*
class Student{
    public String name;
    public int age;
}
public class Test {
    public static void main(String[] args) {
        Student student = new Student();
        System.out.println(student.name);//null
        System.out.println(student.age);//0
        //当成员变量没有被赋值时编译器不会报错，只会以自己数据类型的零值进行输出。
        //引用类型一般为null，基本数据类型为0，char类型为“\u0000”，boolean类型为false。
    }
}*/






/*
//当局部变量名与对象名冲突

class Data{
    public int year;
    public int month;
    public int day;

    public void setDay(int year,int month,int day){
        year = year;//栈区上的局部变量自己给自己赋值，并不影响到引用所指向的对象的成员变量名。
        month = month;//在开辟内存分配的时候，默认值都是0.
        day = day;
    }

    public void printDay(){
        System.out.println("年："+ this.year + " " + "月：" + this.month + " " + "日："
                + this.day + " ");
    }
}

public class Test {
    public static void main(String[] args) {
        Data date = new Data();
        date.setDay(2023 , 7 ,20);
        date.printDay();
        Data date2 = new Data();
        date.setDay(2021 , 1 ,21);
        date.printDay();
    }
}*/





/*
class Data{
    public int year;
    public int month;
    public int day;

    public void setDay(int y,int m,int d){
        this.year = y;
        this.month = m;
        this.day = d;
    }

    public void printDay(){
        System.out.println("年："+ this.year + " " + "月：" + this.month + " " + "日："
                + this.day + " ");
    }
}

public class Test {
    public static void main(String[] args) {
        Data date = new Data();
        date.setDay(2023 , 7 ,20);
        date.printDay();
        Data date2 = new Data();
        date.setDay(2021 , 1 ,21);
        date.printDay();
    }
}*/



/*
class Student{
    public String name;
    public int age;

    public Student(){
        System.out.println("不带参数的构造方法");
    }
    public  Student(String name, int age){
        this.name = name;//zhangsan
        this.age = age;//22
        System.out.println("带2个参数的构造方法");
    }
    public void eat(){
        System.out.println(name + "正在吃饭");//zhangsan正在吃饭
    }
}
public class Test {
    public static void main(String[] args) {
        Student student = new Student();//实例化的对象会自动调用不带参数的构造方法
        Student student2 = new Student("zhangsan",22);//实例化的对象会自动调用带参数的构造方法
    }
}*/





/*
class Student{
    public String name;
    public int age;

    public Student(){
        this("张三" , 10);
        System.out.println("不带参数的构造方法");
    }

    public Student(String name,int age){
        this.name = name;
        this.age = age;
        System.out.println("带2个参数的构造方法");
    }
    public void eat(){
        System.out.println(name + "正在吃饭");
    }
}
public class Test {
    public static void main(String[] args) {
        Student student = new Student();
    }
}*/




/*
class Student{
    public String name;
    public int age;

    public Student(){
        this("张三" , 20);
        System.out.println("不带参数的构造方法");
    }

    public Student(String name, int age){
        this.name = name;
        this.age = age;
        System.out.println("带2个参数的构造方法");
        System.out.println(this.name);
        System.out.println(this.age);
    }

    public void eat(){
        System.out.println(name + "正在吃饭");
    }
}

public class Test{
    public static void main(String[] args){
        Student student = new Student();
    }
}*/






/*
class Person{
    private String name;
    private int age;
    private String sex;

    public Person() {
        this("张三",10,"女");
    }

    public Person(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        System.out.println(this.sex);
        System.out.println(this.age);
        System.out.println(this.name);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
}

public class Test {
    public static void main(String[] args) {
        Person person = new Person();
    }
}*/





/*
class Student{
    private String name;
    private int age;

    public void  eat(){
        System.out.println(this.name + "正在吃饭");
    }

    public String getName(){
        return this.name;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public int getAge() {
        return this.age;
    }

    public void setName(String name){
        this.name = name;
    }
}
public class Test {
    public static void main(String[] args) {
        Student student = new Student();
        student.setName("张三");
        System.out.println(student.getName());
    }
}*/






/*
class Person{
    private String name;
    private int age;
    private String sex;

    public Person() {
        this("张三",10,"女");
    }

    public Person(String name, int age, String sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        System.out.println(this.sex);
        System.out.println(this.age);
        System.out.println(this.name);
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }
}

public class Test {
    public static void main(String[] args) {
        Person person = new Person();
    }
}*/









/*
class Student{
    public String name = "初一";
    public int age = 12;

    public  Student(){
       ;
    }
    public  Student(String name, int age){
        this.name = name;
        this.age = age;
        System.out.println("带2个参数的构造方法");
    }
    public void eat(){
        System.out.println(name + "正在吃饭");//
    }
}
public class Test {
    public static void main(String[] args) {
        Student student = new Student();
    }
}*/


/*
class Student{
    private String name;
    private int age;

    public void setName(String name){
        this.name = name;
    }
    public String getName(){
        return this.name;
    }
    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Student() {
    }
    public Student(String name) {
        this.name = name;
    }

    public Student(int age) {
        this.age = age;
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }
}

public class Test {
    public static void main(String[] args) {
        Student student = new Student();
        student.setName("张三");
        student.setAge(10);
        System.out.println(student.getName());
        Student student2 = new Student("李四",14);
    }
}*/


import static java.lang.Math.*;

/*
public class Test {
    public static void main(String[] args) {
        double ret = Math.sqrt(Math.pow(3,2) + Math.pow(7,5));
        //double ret = sqrt(pow(3,2) + pow(7,5));
        System.out.println(ret);
    }
}*/





/*
class Student{
    private String name;
    private int age;
    public  static String classRoom;

    public Student() {
    }
    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }
}
public class Test {
    public static void main(String[] args) {
        Student student = new Student("张三",10);
        Student student2 = new Student("李四",10);
        System.out.println(student.getAge());
        System.out.println(student2.getAge());

        System.out.println(student.getName());
        System.out.println(student2.getName());

        Student.classRoom = "109";
        System.out.println(Student.classRoom);
    }
}*/





/*import java.util.Arrays;

public class Test {
    public static void main(String[] args) {
        int[] array = { 1, 2 ,3 ,4 };
        System.out.println(Arrays.toString(array));
        java.util.Date date = new java.util.Date();
    }
}*/




/*
class Student{
    //普通成员变量
    private String name;
    private int age;
    //静态成员变量
    public static String classRoom;

    public Student() {
    }

    public Student(String name) {
        this.name = name;
    }

    public Student(int age) {
        this.age = age;
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public void show(){
        System.out.println("姓名：" + name + " 年龄：" + age);
    }
    public static void  func(){
        Student student = new Student();
        student.show();
    }
}

public class Test {
    public static void main(String[] args) {
        Student.classRoom = "109";//静态成员变量直接使用类名.即可访问
        System.out.println(Student.classRoom);

        Student student = new Student();
        student.setAge(17);
        System.out.println(student.getAge());
        student.setName("王五");
        System.out.println(student.getName());
        student.show();
    }
}*/



/*
class Student{
    public String name;
    public int age;
    public static String classRoom ;

    {
        this.name = "小丽";
        this.age = 19;
        System.out.println("实例代码块");
    }
    public Student(){
        System.out.println("不带参数的构造方法");
    }

    static {
        classRoom = "中文一班";
        System.out.println("静态代码块");
    }
    public void show(){
        System.out.println("姓名：" + name + " 年龄：" + age);
    }
}


public class Test {
    public static void main(String[] args) {
        Student student = new Student();
        student.show();
        System.out.println("============");
        Student student2 = new Student();
        student.show();
    }
}*/



/*
class Student{
    public String name;
    public int age;
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Student() {
    }

    public Student(String name, int age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Student{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }
}
public class Test {

    public static void main(String[] args) {
        Student student = new Student("王五",12);
        System.out.println(student);
    }
}*/





/*
class Dog{
    public String name;
    public int age;
    public String color;

    public void eat(){
        System.out.println(this.name + "正在进食");
    }
    public void bark(){
        System.out.println(this.name + "正在吠叫");
    }
}

class Cat{
    public String name;
    public int age;
    public String color;

    public void eat(){
        System.out.println(this.name + "正在进食");
    }
    public void bark(){
        System.out.println(this.name + "正在吠叫");
    }
}
public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.name = "月饼";
        dog.age = 1;
        dog.color = "黄色";
        dog.eat();
        dog.bark();
        System.out.println("=======================");
        Cat cat = new Cat();
        cat.name = "月亮";
        cat.age = 2;
        cat.color = "黑色";
        cat.eat();
        cat.bark();
    }
}*/




/*
class Animals{
    public String name;
    public int age;
    public String color;

    public void eat(){
        System.out.println(this.name + "正在进食");
    }
    public void bark(){
        System.out.println(this.name + "正在吠叫");
    }
}
class Dog extends Animals{
    public String sex;
}

class Cat extends Animals{
    public void swap(){
        System.out.println(this.name + "正在摇尾巴");
    }
}
public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.name = "月饼";
        dog.age = 1;
        dog.color = "黄色";
        dog.eat();
        dog.bark();
        System.out.println("=======================");
        Cat cat = new Cat();
        cat.name = "月亮";
        cat.age = 2;
        cat.color = "黑色";
        cat.eat();
        cat.bark();
    }
}*/





/*
class Base{
    public int a;
    public int b;
}

class Derived extends Base{
    public int c;

    {
        a = 10;
        b = 20;
        c = 30;
    }
}
public class Test {
    public static void main(String[] args) {
        Derived derived = new Derived();
        System.out.println(derived.a);
        System.out.println(derived.b);
        System.out.println(derived.c);
    }
}*/







/*
class Base{
    public int a = 2;
    public int b = 5;
}

class Derived extends Base{
    public int c = 4;
    public int a = 1;
    public int b = 2;
    public void method(){
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
    }
}
public class Test {
    public static void main(String[] args) {
        Derived derived = new Derived();
        derived.method();
    }
}*/









/*
class Base{
    public int a = 2;
    public int b = 5;
}

class Derived extends Base{
    public int c = 4;
    public int a = 1;
    public int b = 2;
    public void method(){
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println(super.a);
        System.out.println(super.b);
    }
}
public class Test {
    public static void main(String[] args) {
        Derived derived = new Derived();
        derived.method();
    }
}*/




/*class Animals{
    public String name;
    public int age;
    public String color;

    public Animals(){

    }
    public Animals(String name){
        this.name = name;
    }
    public void eat(){
        System.out.println(this.name + "正在进食");
    }
    public void bark(){
        System.out.println(this.name + "正在吠叫");
    }
}
class Dog extends Animals{
    public Dog(){
        super();
    }
    public Dog(String name){
        super(name);
    }
    public String sex;
}

public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog();
    }
}*/



/*
class Base{
    public int a = 2;
    public int b = 5;
    public int d = 5;
}

class Derived extends Base{
    public int c = 4;
    public int a = 1;
    public int b = 2;
    public void method(){
        System.out.println(a);
        System.out.println(b);
        System.out.println(c);
        System.out.println(super.a);//2
        System.out.println(super.b);//5
        System.out.println("=====================");
        System.out.println(this.a);//1
        System.out.println(this.b);//2
        System.out.println(this.c);//4
        System.out.println(this.d);//5
    }
}
public class Test {
    public static void main(String[] args) {
        Derived derived = new Derived();
        derived.method();
    }
}*/







/*
class Base{
    public int a = 2;
    public int b = 5;
}

class Derived extends Base{
    public int c = 4;
    public int a = 1;
    public int b = 2;

    public void method(){
        System.out.println(this.a);//打印的是子类的成员变量
        System.out.println(this.b);
        System.out.println(this.c);
    }
}
public class Test {
    public static void main(String[] args) {
        Derived derived = new Derived();
        derived.method();
    }
}*/


/*
class Animal{
    public String name;
    public int age;
    public String color;

    public Animal(){

    }

    public Animal(String name) {
        this.name = name;
    }

    public Animal(int age) {
        this.age = age;
    }

    public Animal(String name,String color){
        this.name = null;
        this.color = color;
    }

    public void eat(){
        System.out.println(name + "正在吃粮");
    }
    public void swap(){
        System.out.println(name + "正在摇尾巴");
    }
}
class Dog extends Animal{
    public void wangWang(){
        System.out.println(name + "正在汪汪叫");
    }

    {
        name = "初一";
        age = 19;
    }
    public Dog() {
        super();
    }
    public Dog(String name) {
        super(name);
    }

    public Dog(int age) {
        super(age);
    }
    public Dog(String name,String color) {
        super(name,color);
    }

}

class Cat extends Animal{
    {
        name = "初二";
        age = 10;
    }
    public Cat() {
        super();
    }
    public Cat(String name) {
        super(name);
    }

    public void miMi(){
        System.out.println(name + "正在喵喵叫");
    }

    public Cat(String name,String color) {
        super(name,color);
    }

    public Cat(int age) {
        super(age);
    }
}

public class Test {
    public static void main(String[] args) {
        Dog dog = new Dog();
        dog.eat();
        dog.swap();
        System.out.println("=============");
        Cat cat = new Cat();
        cat.eat();
        cat.miMi();
    }
}*/



/*
class Animal{
    public String name;
    public int age;
    public String color;

    static {
        System.out.println("Animal的静态代码块");
    }

    {
        System.out.println("Animal的实例代码块");
    }

    public Animal(String name,int age,String color){
        this.name = name;
        this.age = age;
        this.color = color;
        System.out.println("姓名：" + name + " 年龄:" + age + " 颜色:" + color);
    }
    public void eat(){
        System.out.println(name + "正在吃粮食");
    }
    public void swap(){
        System.out.println(name + "正在摇尾巴");
    }
}

public class Test {
    public static void main(String[] args) {
        Animal animal = new Animal("Animal",1,"黑色");
        animal.eat();
        animal.swap();
        System.out.println("==========================");
        Animal animal1 = new Animal("Animal1",2,"白色");
        animal1.eat();
        animal1.swap();
    }
}*/






/*

class Animal{
    public String name;
    public int age;
    public String color;

    static {
        System.out.println("Animal的静态代码块");
    }

    {
        System.out.println("Animal的实例代码块");
    }

    public Animal(){

    }

    public Animal(String name,int age,String color){
        this.name = name;
        this.age = age;
        this.color = color;
        System.out.println("Animal的构造函数");
    }

}

class Dog extends Animal{

    static {
        System.out.println("子类的静态代码块");
    }

    {
        name = "初一";
        age = 19;
        System.out.println("子类的示例代码块");
    }
    public Dog(String name,int age,String color) {
        super(name,age,color);
        System.out.println("子类的构造方法");
    }

}

public class Test {
    public static void main(String[] args) {
        Dog dog1 = new Dog("Dog1",2,"白色");
    }
}*/

